package cn.sf.sufingvideoconsumer.config;

import cn.sf.sufingvideoconsumer.service.IndexService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**
 * index首页的定时任务
 *
 * @author sric
 */
@Component
public class IndexTiming {

    @Resource
    private IndexService indexService;


    /**
     * 定时任务每隔多少秒进行一次
     */
    @Scheduled(fixedRate = 600000)
    public void fixedRateJob() {
        String s = indexService.queryRandom();


        System.out.println("定时任务:" + s);
        if(s==null){
            String queryRandom = indexService.queryRandom();
            System.out.println("第二次请求定时任务:"+queryRandom);
        }

    }

}
